package com.itheima.reggie;

public class AtomiclntegerTest23 {
    public static void main(String[] args) {
        for (int i = 0; i < 20_0000; i++) {
            Threadyu.number++;
        }
        System.out.println(Thread.currentThread().getName()
        +"对变量自增了20万次 number = "+Threadyu.number+"次");
        Threadyu threadyu = new Threadyu();
        threadyu.setName("子线程");
        threadyu.start();


    }
}
class Threadyu extends Thread{
    /**
     * 定义一个共享变量：多个线程操作此变量
     */
   public static Integer number = 0;


    @Override
    public void run() {
        for (int i = 0; i < 20_0000; i++) {
           number++;
        }
        System.out.println(Thread.currentThread().getName()
        +"对变量自增20万次 number ="+Threadyu.number);
    }
}